package com.example.transaction_service_b.service.impl;

import com.example.transaction_service_b.service.EventPublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Created by Administrator on 2017/5/19.
 */
@Service
public class EventPublishImpl implements EventPublishService {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @Override
    public Map<String, Object> selectById(String id) {
        return jdbcTemplate.queryForMap("select * from transaction_eventPublish where id = ?",id);
    }

    @Override
    public boolean updateVersion(Map<String, Object> paramMap) {
        return jdbcTemplate.update("UPDATE transaction_eventPublish SET version = version + 1 WHERE id = ? AND  version = ?",paramMap.get("id"),paramMap.get("version"))>0?true:false;
    }
}
